package com.frxuexi.docment

import com.blankj.utilcode.util.GsonUtils
import com.frxuexi.docment.entity.DocData
import com.frxuexi.docment.entity.DocEntity
import com.frxuexi.lib_http.HttpType
import com.frxuexi.lib_http.NetWorkFactory
import kotlinx.coroutines.flow.Flow
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody

class DocRepository {
    val apiService by lazy { NetWorkFactory.factory(HttpType.NONE).create(ApiService::class.java) }
    fun getFiles(map: Map<String,Any>):Flow<DocData>{
        val json = GsonUtils.toJson(map)
        val body = RequestBody.create("application/json".toMediaTypeOrNull(), json)
        return apiService.getFiles(body)
    }

    fun deleteFile(fildId:Int):Flow<DocData>{
        return apiService.deleteFile(fildId = fildId)
    }
}